﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace LyncServerExtension.GenericResult
{
    /// <summary>
    /// Class to represent a generic web page result which can be reused web based result builders.
    /// </summary>
    public abstract class WebPage : ILyncResult
    {
        /// <summary>
        /// Gets the title.
        /// </summary>
        public abstract string Title { get; }

        /// <summary>
        /// Gets the content.
        /// </summary>
        public abstract string Content { get; }

        /// <summary>
        /// Gets the mime-type.
        /// </summary>
        /// <value>
        /// The mime-type of the result.
        /// </value>
        public string MimeType
        {
            get { return "text/html"; }
        }

        /// <summary>
        /// Writes this result to the given stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        public void Write(Stream stream)
        {
            StreamWriter writer = new StreamWriter(stream);

            writer.Write("<html><head><title>{0}</title></head><body>{1}</body></html>", Title, Content);
            writer.Flush();
        }
    }
}
